import router from "./router";
import { getUserToken } from "@/utils/storage";
// import NProgress from "nprogress";
// import "nprogress/nprogress.css";

// NProgress.configure({ showSpinner: false });

router.beforeEach(async (to, from, next) => {
  // NProgress.start();
  const token = getUserToken();
  if (to.path === "/login") {
    next();
  } else {
    // 判断有木有token
    if (token) {
      next();
    } else {
      next("/login");
    }
  }
});

// router.afterEach(() => {
//   // NProgress.done();
// });
